package net.example.model;

import com.oraycn.omcs.utils.SerializeUtils;

import java.io.IOException;
import java.util.Date;

import io.netty.buffer.ByteBuf;

/**
 * Created by ZN on 2015/12/5.
 */
public class LastWordsRecord {
    private  int LastWordsRecordLen;
    private  String AudienceID;
    private  int ChatContentLen;
    private  byte[] ChatContent;
    private  boolean IsGroup;
    private  String SpeekerID;
    private Date SpeakTime;

    public void deserialize(ByteBuf buffer) throws IOException {
        this.LastWordsRecordLen = buffer.readInt();
        if (this.LastWordsRecordLen > 0) {
            this.AudienceID = SerializeUtils.readStrIntLen(buffer);
            this.ChatContentLen = buffer.readInt();
            this.ChatContent = new byte[this.ChatContentLen];
            buffer.readBytes(this.ChatContent);
            this.IsGroup = buffer.readByte() == (byte) 1;
            this.SpeekerID = SerializeUtils.readStrIntLen(buffer);
            this.SpeakTime = new Date(buffer.readLong());
        }
    }
}
